perf(tui): bring async to tui #9132
Merged
+127
−85
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR makes the driving the TUI async, the actual operation on the state is still completely sync. The primary driver behind this PR is it allows us to make use of
crossterm::event::EventStream
which seems to be far more performant than polling for user input.The first commit of the PR just changes types from
std::sync::mpsc
totokio::sync::mpsc
(and make use oftokio::sync::oneshot
for our callbacks instead of a channel of size 1).The second commit removes our usage of
crossterm::event::poll
in favor of a dedicated task that reads and forwards events fromcrossterm::event::EventStream
.The final commit moves the production of ticks to it's own task to avoid the need for timing out our reads.
Testing Instructions
Notice large reduction in CPU usage from
turbo
when tasks are not producing output and the TUI is just waiting for user input.Before
After